home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / demos / VisualAge for Java 2.0 Entry / setup / data1.cab / ide-e / IDE / cache / 1P67CG (.txt) < prev    next >
Encoding:
Java Class File  |  1998-09-16  |  24.0 KB  |  1,027 lines

  1. package com.sun.java.swing;
  2.  
  3. import com.sun.java.accessibility.Accessible;
  4. import com.sun.java.accessibility.AccessibleContext;
  5. import com.sun.java.accessibility.AccessibleState;
  6. import com.sun.java.swing.event.EventListenerList;
  7. import com.sun.java.swing.event.TreeExpansionEvent;
  8. import com.sun.java.swing.event.TreeExpansionListener;
  9. import com.sun.java.swing.event.TreeSelectionEvent;
  10. import com.sun.java.swing.event.TreeSelectionListener;
  11. import com.sun.java.swing.plaf.TreeUI;
  12. import com.sun.java.swing.tree.DefaultMutableTreeNode;
  13. import com.sun.java.swing.tree.DefaultTreeModel;
  14. import com.sun.java.swing.tree.DefaultTreeSelectionModel;
  15. import com.sun.java.swing.tree.TreeCellEditor;
  16. import com.sun.java.swing.tree.TreeCellRenderer;
  17. import com.sun.java.swing.tree.TreeModel;
  18. import com.sun.java.swing.tree.TreeNode;
  19. import com.sun.java.swing.tree.TreePath;
  20. import com.sun.java.swing.tree.TreeSelectionModel;
  21. import java.awt.AWTEvent;
  22. import java.awt.Component;
  23. import java.awt.Container;
  24. import java.awt.Dimension;
  25. import java.awt.LayoutManager;
  26. import java.awt.Point;
  27. import java.awt.Rectangle;
  28. import java.awt.event.InputEvent;
  29. import java.awt.event.MouseEvent;
  30. import java.io.IOException;
  31. import java.io.ObjectInputStream;
  32. import java.io.ObjectOutputStream;
  33. import java.io.Serializable;
  34. import java.util.Hashtable;
  35. import java.util.Vector;
  36.  
  37. public class JTree extends JComponent implements Scrollable, Accessible {
  38.    protected transient TreeModel treeModel;
  39.    protected transient TreeSelectionModel selectionModel;
  40.    protected boolean rootVisible;
  41.    protected transient TreeCellRenderer cellRenderer;
  42.    protected int rowHeight;
  43.    protected boolean showsRootHandles;
  44.    protected TreeSelectionRedirector selectionRedirector;
  45.    protected transient TreeCellEditor cellEditor;
  46.    protected boolean editable;
  47.    protected boolean largeModel;
  48.    protected int visibleRowCount;
  49.    protected boolean invokesStopCellEditing;
  50.    public static final String CELL_RENDERER_PROPERTY = "cellRenderer";
  51.    public static final String TREE_MODEL_PROPERTY = "treeModel";
  52.    public static final String ROOT_VISIBLE_PROPERTY = "rootVisible";
  53.    public static final String SHOWS_ROOT_HANDLES_PROPERTY = "showsRootHandles";
  54.    public static final String ROW_HEIGHT_PROPERTY = "rowHeight";
  55.    public static final String CELL_EDITOR_PROPERTY = "cellEditor";
  56.    public static final String EDITABLE_PROPERTY = "editable";
  57.    public static final String LARGE_MODEL_PROPERTY = "largeModel";
  58.    public static final String SELECTION_MODEL_PROPERTY = "selectionModel";
  59.    public static final String VISIBLE_ROW_COUNT_PROPERTY = "visibleRowCount";
  60.    public static final String INVOKES_STOP_CELL_EDITING_PROPERTY = "messagesStopCellEditing";
  61.    static Class class$com$sun$java$swing$event$TreeExpansionListener;
  62.    static Class class$com$sun$java$swing$event$TreeSelectionListener;
  63.  
  64.    public JTree() {
  65.       this(getDefaultTreeModel());
  66.    }
  67.  
  68.    public JTree(Object[] value) {
  69.       this(createTreeModel(value));
  70.       this.setRootVisible(false);
  71.       this.setShowsRootHandles(true);
  72.    }
  73.  
  74.    public JTree(TreeModel newModel) {
  75.       ((Container)this).setLayout((LayoutManager)null);
  76.       this.rowHeight = 16;
  77.       this.visibleRowCount = 20;
  78.       this.rootVisible = true;
  79.       this.selectionModel = new DefaultTreeSelectionModel();
  80.       this.cellRenderer = null;
  81.       this.updateUI();
  82.       this.setModel(newModel);
  83.    }
  84.  
  85.    public JTree(TreeNode root) {
  86.       this(root, false);
  87.    }
  88.  
  89.    public JTree(TreeNode root, boolean asksAllowsChildren) {
  90.       this((TreeModel)(new DefaultTreeModel(root, asksAllowsChildren)));
  91.    }
  92.  
  93.    public JTree(Hashtable value) {
  94.       this(createTreeModel(value));
  95.       this.setRootVisible(false);
  96.       this.setShowsRootHandles(true);
  97.    }
  98.  
  99.    public JTree(Vector value) {
  100.       this(createTreeModel(value));
  101.       this.setRootVisible(false);
  102.       this.setShowsRootHandles(true);
  103.    }
  104.  
  105.    public void addSelectionInterval(int index0, int index1) {
  106.       TreePath[] paths = this.getPathBetweenRows(index0, index1);
  107.       this.getSelectionModel().addSelectionPaths(paths);
  108.       if (super.accessibleContext != null) {
  109.          ((AccessibleJTree)super.accessibleContext).fireSelectionPropertyChange();
  110.       }
  111.  
  112.    }
  113.  
  114.    public void addSelectionPath(TreePath path) {
  115.       this.getSelectionModel().addSelectionPath(path);
  116.       if (super.accessibleContext != null) {
  117.          ((AccessibleJTree)super.accessibleContext).fireSelectionPropertyChange();
  118.       }
  119.  
  120.    }
  121.  
  122.    public void addSelectionPaths(TreePath[] paths) {
  123.       this.getSelectionModel().addSelectionPaths(paths);
  124.       if (super.accessibleContext != null) {
  125.          ((AccessibleJTree)super.accessibleContext).fireSelectionPropertyChange();
  126.       }
  127.  
  128.    }
  129.  
  130.    public void addSelectionRow(int row) {
  131.       int[] rows = new int[]{row};
  132.       this.addSelectionRows(rows);
  133.    }
  134.  
  135.    public void addSelectionRows(int[] rows) {
  136.       TreeUI ui = this.getUI();
  137.       if (ui != null && rows != null) {
  138.          int numRows = rows.length;
  139.          TreePath[] paths = new TreePath[numRows];
  140.  
  141.          for(int counter = 0; counter < numRows; ++counter) {
  142.             paths[counter] = ui.getPathForRow(rows[counter]);
  143.          }
  144.  
  145.          this.addSelectionPaths(paths);
  146.       }
  147.  
  148.    }
  149.  
  150.    public void addTreeExpansionListener(TreeExpansionListener tel) {
  151.       EventListenerList var10000 = super.listenerList;
  152.       Class var10001 = class$com$sun$java$swing$event$TreeExpansionListener;
  153.       if (var10001 == null) {
  154.          try {
  155.             var10001 = Class.forName("com.sun.java.swing.event.TreeExpansionListener");
  156.          } catch (ClassNotFoundException var2) {
  157.             throw new NoClassDefFoundError(((Throwable)var2).getMessage());
  158.          }
  159.  
  160.          class$com$sun$java$swing$event$TreeExpansionListener = var10001;
  161.       }
  162.  
  163.       var10000.add(var10001, tel);
  164.    }
  165.  
  166.    public void addTreeSelectionListener(TreeSelectionListener tsl) {
  167.       EventListenerList var10000 = super.listenerList;
  168.       Class var10001 = class$com$sun$java$swing$event$TreeSelectionListener;
  169.       if (var10001 == null) {
  170.          try {
  171.             var10001 = Class.forName("com.sun.java.swing.event.TreeSelectionListener");
  172.          } catch (ClassNotFoundException var3) {
  173.             throw new NoClassDefFoundError(((Throwable)var3).getMessage());
  174.          }
  175.  
  176.          class$com$sun$java$swing$event$TreeSelectionListener = var10001;
  177.       }
  178.  
  179.       var10000.add(var10001, tsl);
  180.       var10000 = super.listenerList;
  181.       var10001 = class$com$sun$java$swing$event$TreeSelectionListener;
  182.       if (var10001 == null) {
  183.          try {
  184.             var10001 = Class.forName("com.sun.java.swing.event.TreeSelectionListener");
  185.          } catch (ClassNotFoundException var2) {
  186.             throw new NoClassDefFoundError(((Throwable)var2).getMessage());
  187.          }
  188.  
  189.          class$com$sun$java$swing$event$TreeSelectionListener = var10001;
  190.       }
  191.  
  192.       if (var10000.getListenerCount(var10001) != 0 && this.selectionRedirector == null) {
  193.          this.selectionRedirector = new TreeSelectionRedirector(this);
  194.          this.selectionModel.addTreeSelectionListener(this.selectionRedirector);
  195.       }
  196.  
  197.    }
  198.  
  199.    public void clearSelection() {
  200.       this.getSelectionModel().clearSelection();
  201.       if (super.accessibleContext != null) {
  202.          ((AccessibleJTree)super.accessibleContext).fireSelectionPropertyChange();
  203.       }
  204.  
  205.    }
  206.  
  207.    public void collapsePath(TreePath path) {
  208.       TreeUI tree = this.getUI();
  209.       if (tree != null) {
  210.          tree.collapsePath(path);
  211.          if (super.accessibleContext != null) {
  212.             ((AccessibleJTree)super.accessibleContext).fireVisibleDataPropertyChange();
  213.          }
  214.       }
  215.  
  216.    }
  217.  
  218.    public void collapseRow(int row) {
  219.       TreeUI tree = this.getUI();
  220.       if (tree != null) {
  221.          tree.collapseRow(row);
  222.          if (super.accessibleContext != null) {
  223.             ((AccessibleJTree)super.accessibleContext).fireVisibleDataPropertyChange();
  224.          }
  225.       }
  226.  
  227.    }
  228.  
  229.    public String convertValueToText(Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
  230.       return value != null ? value.toString() : "";
  231.    }
  232.  
  233.    protected static TreeModel createTreeModel(Object value) {
  234.       Object root;
  235.       if (!(value instanceof Object[]) && !(value instanceof Hashtable) && !(value instanceof Vector)) {
  236.          root = new DynamicUtilTreeNode("root", value);
  237.       } else {
  238.          root = new DefaultMutableTreeNode("root");
  239.          com.sun.java.swing.JTree.DynamicUtilTreeNode.createChildren((DefaultMutableTreeNode)root, value);
  240.       }
  241.  
  242.       return new DefaultTreeModel((TreeNode)root, false);
  243.    }
  244.  
  245.    public void expandPath(TreePath path) {
  246.       TreeUI tree = this.getUI();
  247.       if (tree != null) {
  248.          tree.expandPath(path);
  249.          if (super.accessibleContext != null) {
  250.             ((AccessibleJTree)super.accessibleContext).fireVisibleDataPropertyChange();
  251.          }
  252.       }
  253.  
  254.    }
  255.  
  256.    public void expandRow(int row) {
  257.       TreeUI tree = this.getUI();
  258.       if (tree != null) {
  259.          tree.expandRow(row);
  260.          if (super.accessibleContext != null) {
  261.             ((AccessibleJTree)super.accessibleContext).fireVisibleDataPropertyChange();
  262.          }
  263.       }
  264.  
  265.    }
  266.  
  267.    public void fireTreeCollapsed(TreePath path) {
  268.       Object[] listeners = super.listenerList.getListenerList();
  269.       TreeExpansionEvent e = null;
  270.  
  271.       for(int i = listeners.length - 2; i >= 0; i -= 2) {
  272.          Object var10000 = listeners[i];
  273.          Class var10001 = class$com$sun$java$swing$event$TreeExpansionListener;
  274.          if (var10001 == null) {
  275.             try {
  276.                var10001 = Class.forName("com.sun.java.swing.event.TreeExpansionListener");
  277.             } catch (ClassNotFoundException var5) {
  278.                throw new NoClassDefFoundError(((Throwable)var5).getMessage());
  279.             }
  280.  
  281.             class$com$sun$java$swing$event$TreeExpansionListener = var10001;
  282.          }
  283.  
  284.          if (var10000 == var10001) {
  285.             if (e == null) {
  286.                e = new TreeExpansionEvent(this, path);
  287.             }
  288.  
  289.             ((TreeExpansionListener)listeners[i + 1]).treeCollapsed(e);
  290.          }
  291.       }
  292.  
  293.    }
  294.  
  295.    public void fireTreeExpanded(TreePath path) {
  296.       Object[] listeners = super.listenerList.getListenerList();
  297.       TreeExpansionEvent e = null;
  298.  
  299.       for(int i = listeners.length - 2; i >= 0; i -= 2) {
  300.          Object var10000 = listeners[i];
  301.          Class var10001 = class$com$sun$java$swing$event$TreeExpansionListener;
  302.          if (var10001 == null) {
  303.             try {
  304.                var10001 = Class.forName("com.sun.java.swing.event.TreeExpansionListener");
  305.             } catch (ClassNotFoundException var5) {
  306.                throw new NoClassDefFoundError(((Throwable)var5).getMessage());
  307.             }
  308.  
  309.             class$com$sun$java$swing$event$TreeExpansionListener = var10001;
  310.          }
  311.  
  312.          if (var10000 == var10001) {
  313.             if (e == null) {
  314.                e = new TreeExpansionEvent(this, path);
  315.             }
  316.  
  317.             ((TreeExpansionListener)listeners[i + 1]).treeExpanded(e);
  318.          }
  319.       }
  320.  
  321.    }
  322.  
  323.    protected void fireValueChanged(TreeSelectionEvent e) {
  324.       Object[] listeners = super.listenerList.getListenerList();
  325.  
  326.       for(int i = listeners.length - 2; i >= 0; i -= 2) {
  327.          Object var10000 = listeners[i];
  328.          Class var10001 = class$com$sun$java$swing$event$TreeSelectionListener;
  329.          if (var10001 == null) {
  330.             try {
  331.                var10001 = Class.forName("com.sun.java.swing.event.TreeSelectionListener");
  332.             } catch (ClassNotFoundException var4) {
  333.                throw new NoClassDefFoundError(((Throwable)var4).getMessage());
  334.             }
  335.  
  336.             class$com$sun$java$swing$event$TreeSelectionListener = var10001;
  337.          }
  338.  
  339.          if (var10000 == var10001) {
  340.             ((TreeSelectionListener)listeners[i + 1]).valueChanged(e);
  341.          }
  342.       }
  343.  
  344.    }
  345.  
  346.    public AccessibleContext getAccessibleContext() {
  347.       if (super.accessibleContext == null) {
  348.          super.accessibleContext = new AccessibleJTree(this);
  349.       }
  350.  
  351.       return super.accessibleContext;
  352.    }
  353.  
  354.    public TreeCellEditor getCellEditor() {
  355.       return this.cellEditor;
  356.    }
  357.  
  358.    public TreeCellRenderer getCellRenderer() {
  359.       return this.cellRenderer;
  360.    }
  361.  
  362.    public TreePath getClosestPathForLocation(int x, int y) {
  363.       TreeUI tree = this.getUI();
  364.       return tree != null ? tree.getClosestPathForLocation(x, y) : null;
  365.    }
  366.  
  367.    public int getClosestRowForLocation(int x, int y) {
  368.       TreeUI tree = this.getUI();
  369.       return tree != null ? tree.getClosestRowForLocation(x, y) : -1;
  370.    }
  371.  
  372.    protected static TreeModel getDefaultTreeModel() {
  373.       DefaultMutableTreeNode root = new DefaultMutableTreeNode("root");
  374.       DefaultMutableTreeNode child = new DefaultMutableTreeNode("swing");
  375.       root.add(child);
  376.       DefaultMutableTreeNode parent = child;
  377.       child = new DefaultMutableTreeNode("is");
  378.       parent.add(child);
  379.       parent = child;
  380.       child = new DefaultMutableTreeNode("cool");
  381.       parent.add(child);
  382.       return new DefaultTreeModel(root);
  383.    }
  384.  
  385.    public TreePath getEditingPath() {
  386.       TreeUI tree = this.getUI();
  387.       return tree != null ? tree.getEditingPath() : null;
  388.    }
  389.  
  390.    public boolean getInvokesStopCellEditing() {
  391.       return this.invokesStopCellEditing;
  392.    }
  393.  
  394.    public Object getLastSelectedPathComponent() {
  395.       TreePath selPath = this.getSelectionModel().getSelectionPath();
  396.       return selPath != null ? selPath.getLastPathComponent() : null;
  397.    }
  398.  
  399.    public TreePath getLeadSelectionPath() {
  400.       return this.getSelectionModel().getLeadSelectionPath();
  401.    }
  402.  
  403.    public int getLeadSelectionRow() {
  404.       return this.getSelectionModel().getLeadSelectionRow();
  405.    }
  406.  
  407.    public int getMaxSelectionRow() {
  408.       return this.getSelectionModel().getMaxSelectionRow();
  409.    }
  410.  
  411.    public int getMinSelectionRow() {
  412.       return this.getSelectionModel().getMinSelectionRow();
  413.    }
  414.  
  415.    public TreeModel getModel() {
  416.       return this.treeModel;
  417.    }
  418.  
  419.    protected TreePath[] getPathBetweenRows(int index0, int index1) {
  420.       TreeUI tree = this.getUI();
  421.       int newMinIndex = Math.min(index0, index1);
  422.       int newMaxIndex = Math.max(index0, index1);
  423.       if (tree == null) {
  424.          return null;
  425.       } else {
  426.          TreePath[] selection = new TreePath[newMaxIndex - newMinIndex + 1];
  427.  
  428.          for(int counter = newMinIndex; counter <= newMaxIndex; ++counter) {
  429.             selection[counter - newMinIndex] = tree.getPathForRow(counter);
  430.          }
  431.  
  432.          return selection;
  433.       }
  434.    }
  435.  
  436.    public Rectangle getPathBounds(TreePath path) {
  437.       TreeUI tree = this.getUI();
  438.       return tree != null ? tree.getPathBounds(path) : null;
  439.    }
  440.  
  441.    public TreePath getPathForLocation(int x, int y) {
  442.       TreePath closestPath = this.getClosestPathForLocation(x, y);
  443.       if (closestPath != null) {
  444.          Rectangle pathBounds = this.getPathBounds(closestPath);
  445.          if (x >= pathBounds.x && x < pathBounds.x + pathBounds.width && y >= pathBounds.y && y < pathBounds.y + pathBounds.height) {
  446.             return closestPath;
  447.          }
  448.       }
  449.  
  450.       return null;
  451.    }
  452.  
  453.    public TreePath getPathForRow(int row) {
  454.       TreeUI tree = this.getUI();
  455.       return tree != null ? tree.getPathForRow(row) : null;
  456.    }
  457.  
  458.    public Dimension getPreferredScrollableViewportSize() {
  459.       int width = ((JComponent)this).getPreferredSize().width;
  460.       int visRows = this.getVisibleRowCount();
  461.       int height;
  462.       if (this.isFixedRowHeight()) {
  463.          height = visRows * this.getRowHeight();
  464.       } else {
  465.          TreeUI ui = this.getUI();
  466.          if (ui != null && ui.getRowCount() > 0) {
  467.             height = this.getRowBounds(0).height * visRows;
  468.          } else {
  469.             height = 16 * visRows;
  470.          }
  471.       }
  472.  
  473.       return new Dimension(width, height);
  474.    }
  475.  
  476.    public Rectangle getRowBounds(int row) {
  477.       TreeUI tree = this.getUI();
  478.       return tree != null ? tree.getRowBounds(row) : null;
  479.    }
  480.  
  481.    public int getRowCount() {
  482.       TreeUI tree = this.getUI();
  483.       return tree != null ? tree.getRowCount() : 0;
  484.    }
  485.  
  486.    public int getRowForLocation(int x, int y) {
  487.       int closestRow = this.getClosestRowForLocation(x, y);
  488.       if (closestRow != -1) {
  489.          Rectangle rowBounds = this.getRowBounds(closestRow);
  490.          if (x >= rowBounds.x && x < rowBounds.x + rowBounds.width && y >= rowBounds.y && y < rowBounds.y + rowBounds.height) {
  491.             return closestRow;
  492.          }
  493.       }
  494.  
  495.       return -1;
  496.    }
  497.  
  498.    public int getRowForPath(TreePath path) {
  499.       TreeUI tree = this.getUI();
  500.       return tree != null ? tree.getRowForPath(path) : -1;
  501.    }
  502.  
  503.    public int getRowHeight() {
  504.       return this.rowHeight;
  505.    }
  506.  
  507.    public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction) {
  508.       return orientation == 1 ? visibleRect.height : visibleRect.width;
  509.    }
  510.  
  511.    public boolean getScrollableTracksViewportHeight() {
  512.       return false;
  513.    }
  514.  
  515.    public boolean getScrollableTracksViewportWidth() {
  516.       return false;
  517.    }
  518.  
  519.    public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction) {
  520.       if (orientation == 1) {
  521.          int firstIndex = this.getClosestRowForLocation(0, visibleRect.y);
  522.          if (firstIndex != -1) {
  523.             Rectangle rowBounds = this.getRowBounds(firstIndex);
  524.             if (rowBounds.y != visibleRect.y) {
  525.                if (direction < 0) {
  526.                   return visibleRect.y - rowBounds.y;
  527.                }
  528.  
  529.                return rowBounds.y + rowBounds.height - visibleRect.y;
  530.             }
  531.  
  532.             if (direction >= 0) {
  533.                return rowBounds.height;
  534.             }
  535.  
  536.             if (firstIndex != 0) {
  537.                rowBounds = this.getRowBounds(firstIndex - 1);
  538.                return rowBounds.height;
  539.             }
  540.          }
  541.  
  542.          return 0;
  543.       } else {
  544.          return 4;
  545.       }
  546.    }
  547.  
  548.    public int getSelectionCount() {
  549.       return this.selectionModel.getSelectionCount();
  550.    }
  551.  
  552.    public TreeSelectionModel getSelectionModel() {
  553.       return this.selectionModel;
  554.    }
  555.  
  556.    public TreePath getSelectionPath() {
  557.       return this.getSelectionModel().getSelectionPath();
  558.    }
  559.  
  560.    public TreePath[] getSelectionPaths() {
  561.       return this.getSelectionModel().getSelectionPaths();
  562.    }
  563.  
  564.    public int[] getSelectionRows() {
  565.       return this.getSelectionModel().getSelectionRows();
  566.    }
  567.  
  568.    public boolean getShowsRootHandles() {
  569.       return this.showsRootHandles;
  570.    }
  571.  
  572.    public String getToolTipText(MouseEvent event) {
  573.       if (event != null) {
  574.          Point p = event.getPoint();
  575.          int selRow = this.getRowForLocation(p.x, p.y);
  576.          TreeCellRenderer r = this.getCellRenderer();
  577.          if (selRow != -1 && r != null) {
  578.             TreePath path = this.getPathForRow(selRow);
  579.             Object lastPath = path.getLastPathComponent();
  580.             Component rComponent = r.getTreeCellRendererComponent(this, lastPath, this.isRowSelected(selRow), this.isExpanded(selRow), this.getModel().isLeaf(lastPath), selRow, true);
  581.             if (rComponent instanceof JComponent) {
  582.                Rectangle pathBounds = this.getPathBounds(path);
  583.                p.translate(-pathBounds.x, -pathBounds.y);
  584.                MouseEvent newEvent = new MouseEvent(rComponent, ((AWTEvent)event).getID(), ((InputEvent)event).getWhen(), ((InputEvent)event).getModifiers(), p.x, p.y, event.getClickCount(), event.isPopupTrigger());
  585.                return ((JComponent)rComponent).getToolTipText(newEvent);
  586.             }
  587.          }
  588.       }
  589.  
  590.       return null;
  591.    }
  592.  
  593.    public TreeUI getUI() {
  594.       return (TreeUI)super.ui;
  595.    }
  596.  
  597.    public String getUIClassID() {
  598.       return "TreeUI";
  599.    }
  600.  
  601.    public int getVisibleRowCount() {
  602.       return this.visibleRowCount;
  603.    }
  604.  
  605.    public boolean isCollapsed(int row) {
  606.       TreeUI tree = this.getUI();
  607.       return tree != null ? tree.isCollapsed(row) : false;
  608.    }
  609.  
  610.    public boolean isCollapsed(TreePath path) {
  611.       TreeUI tree = this.getUI();
  612.       return tree != null ? tree.isCollapsed(path) : false;
  613.    }
  614.  
  615.    public boolean isEditable() {
  616.       return this.editable;
  617.    }
  618.  
  619.    public boolean isEditing() {
  620.       TreeUI tree = this.getUI();
  621.       return tree != null ? tree.isEditing() : false;
  622.    }
  623.  
  624.    public boolean isExpanded(int row) {
  625.       TreeUI tree = this.getUI();
  626.       return tree != null ? tree.isExpanded(row) : false;
  627.    }
  628.  
  629.    public boolean isExpanded(TreePath path) {
  630.       TreeUI tree = this.getUI();
  631.       return tree != null ? tree.isExpanded(path) : false;
  632.    }
  633.  
  634.    public boolean isFixedRowHeight() {
  635.       return this.rowHeight > 0;
  636.    }
  637.  
  638.    public boolean isLargeModel() {
  639.       return this.largeModel;
  640.    }
  641.  
  642.    public boolean isOpaque() {
  643.       return true;
  644.    }
  645.  
  646.    public boolean isPathEditable(TreePath path) {
  647.       return this.isEditable();
  648.    }
  649.  
  650.    public boolean isPathSelected(TreePath path) {
  651.       return this.getSelectionModel().isPathSelected(path);
  652.    }
  653.  
  654.    public boolean isRootVisible() {
  655.       return this.rootVisible;
  656.    }
  657.  
  658.    public boolean isRowSelected(int row) {
  659.       return this.getSelectionModel().isRowSelected(row);
  660.    }
  661.  
  662.    public boolean isSelectionEmpty() {
  663.       return this.getSelectionModel().isSelectionEmpty();
  664.    }
  665.  
  666.    public boolean isVisible(TreePath path) {
  667.       TreeUI tree = this.getUI();
  668.       return tree != null ? tree.isVisible(path) : false;
  669.    }
  670.  
  671.    public void makeVisible(TreePath path) {
  672.       TreeUI tree = this.getUI();
  673.       if (tree != null) {
  674.          tree.makeVisible(path);
  675.          if (super.accessibleContext != null) {
  676.             ((AccessibleJTree)super.accessibleContext).fireVisibleDataPropertyChange();
  677.          }
  678.       }
  679.  
  680.    }
  681.  
  682.    private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException {
  683.       s.defaultReadObject();
  684.       Vector values = (Vector)s.readObject();
  685.       int indexCounter = 0;
  686.       int maxCounter = values.size();
  687.       if (indexCounter < maxCounter && values.elementAt(indexCounter).equals("cellRenderer")) {
  688.          ++indexCounter;
  689.          this.cellRenderer = (TreeCellRenderer)values.elementAt(indexCounter);
  690.          ++indexCounter;
  691.       }
  692.  
  693.       if (indexCounter < maxCounter && values.elementAt(indexCounter).equals("cellEditor")) {
  694.          ++indexCounter;
  695.          this.cellEditor = (TreeCellEditor)values.elementAt(indexCounter);
  696.          ++indexCounter;
  697.       }
  698.  
  699.       if (indexCounter < maxCounter && values.elementAt(indexCounter).equals("treeModel")) {
  700.          ++indexCounter;
  701.          this.treeModel = (TreeModel)values.elementAt(indexCounter);
  702.          ++indexCounter;
  703.       }
  704.  
  705.       if (indexCounter < maxCounter && values.elementAt(indexCounter).equals("selectionModel")) {
  706.          ++indexCounter;
  707.          this.selectionModel = (TreeSelectionModel)values.elementAt(indexCounter);
  708.          ++indexCounter;
  709.       }
  710.  
  711.    }
  712.  
  713.    public void removeSelectionInterval(int index0, int index1) {
  714.       TreePath[] paths = this.getPathBetweenRows(index0, index1);
  715.       this.getSelectionModel().removeSelectionPaths(paths);
  716.       if (super.accessibleContext != null) {
  717.          ((AccessibleJTree)super.accessibleContext).fireSelectionPropertyChange();
  718.       }
  719.  
  720.    }
  721.  
  722.    public void removeSelectionPath(TreePath path) {
  723.       this.getSelectionModel().removeSelectionPath(path);
  724.       if (super.accessibleContext != null) {
  725.          ((AccessibleJTree)super.accessibleContext).fireSelectionPropertyChange();
  726.       }
  727.  
  728.    }
  729.  
  730.    public void removeSelectionPaths(TreePath[] paths) {
  731.       this.getSelectionModel().removeSelectionPaths(paths);
  732.       if (super.accessibleContext != null) {
  733.          ((AccessibleJTree)super.accessibleContext).fireSelectionPropertyChange();
  734.       }
  735.  
  736.    }
  737.  
  738.    public void removeSelectionRow(int row) {
  739.       int[] rows = new int[]{row};
  740.       this.removeSelectionRows(rows);
  741.    }
  742.  
  743.    public void removeSelectionRows(int[] rows) {
  744.       TreeUI ui = this.getUI();
  745.       if (ui != null && rows != null) {
  746.          int numRows = rows.length;
  747.          TreePath[] paths = new TreePath[numRows];
  748.  
  749.          for(int counter = 0; counter < numRows; ++counter) {
  750.             paths[counter] = ui.getPathForRow(rows[counter]);
  751.          }
  752.  
  753.          this.removeSelectionPaths(paths);
  754.       }
  755.  
  756.    }
  757.  
  758.    public void removeTreeExpansionListener(TreeExpansionListener tel) {
  759.       EventListenerList var10000 = super.listenerList;
  760.       Class var10001 = class$com$sun$java$swing$event$TreeExpansionListener;
  761.       if (var10001 == null) {
  762.          try {
  763.             var10001 = Class.forName("com.sun.java.swing.event.TreeExpansionListener");
  764.          } catch (ClassNotFoundException var2) {
  765.             throw new NoClassDefFoundError(((Throwable)var2).getMessage());
  766.          }
  767.  
  768.          class$com$sun$java$swing$event$TreeExpansionListener = var10001;
  769.       }
  770.  
  771.       var10000.remove(var10001, tel);
  772.    }
  773.  
  774.    public void removeTreeSelectionListener(TreeSelectionListener tsl) {
  775.       EventListenerList var10000 = super.listenerList;
  776.       Class var10001 = class$com$sun$java$swing$event$TreeSelectionListener;
  777.       if (var10001 == null) {
  778.          try {
  779.             var10001 = Class.forName("com.sun.java.swing.event.TreeSelectionListener");
  780.          } catch (ClassNotFoundException var3) {
  781.             throw new NoClassDefFoundError(((Throwable)var3).getMessage());
  782.          }
  783.  
  784.          class$com$sun$java$swing$event$TreeSelectionListener = var10001;
  785.       }
  786.  
  787.       var10000.remove(var10001, tsl);
  788.       var10000 = super.listenerList;
  789.       var10001 = class$com$sun$java$swing$event$TreeSelectionListener;
  790.       if (var10001 == null) {
  791.          try {
  792.             var10001 = Class.forName("com.sun.java.swing.event.TreeSelectionListener");
  793.          } catch (ClassNotFoundException var2) {
  794.             throw new NoClassDefFoundError(((Throwable)var2).getMessage());
  795.          }
  796.  
  797.          class$com$sun$java$swing$event$TreeSelectionListener = var10001;
  798.       }
  799.  
  800.       if (var10000.getListenerCount(var10001) == 0 && this.selectionRedirector != null) {
  801.          this.selectionModel.removeTreeSelectionListener(this.selectionRedirector);
  802.          this.selectionRedirector = null;
  803.       }
  804.  
  805.    }
  806.  
  807.    public void scrollPathToVisible(TreePath path) {
  808.       TreeUI tree = this.getUI();
  809.       if (tree != null) {
  810.          tree.scrollPathToVisible(path);
  811.          if (super.accessibleContext != null) {
  812.             ((AccessibleJTree)super.accessibleContext).fireVisibleDataPropertyChange();
  813.          }
  814.       }
  815.  
  816.    }
  817.  
  818.    public void scrollRowToVisible(int row) {
  819.       TreeUI tree = this.getUI();
  820.       if (tree != null) {
  821.          tree.scrollRowToVisible(row);
  822.          if (super.accessibleContext != null) {
  823.             ((AccessibleJTree)super.accessibleContext).fireVisibleDataPropertyChange();
  824.          }
  825.       }
  826.  
  827.    }
  828.  
  829.    public void setCellEditor(TreeCellEditor cellEditor) {
  830.       TreeCellEditor oldEditor = this.cellEditor;
  831.       this.cellEditor = cellEditor;
  832.       ((JComponent)this).firePropertyChange("cellEditor", oldEditor, cellEditor);
  833.       ((Container)this).invalidate();
  834.    }
  835.  
  836.    public void setCellRenderer(TreeCellRenderer x) {
  837.       TreeCellRenderer oldValue = this.cellRenderer;
  838.       this.cellRenderer = x;
  839.       ((JComponent)this).firePropertyChange("cellRenderer", oldValue, this.cellRenderer);
  840.       ((Container)this).invalidate();
  841.    }
  842.  
  843.    public void setEditable(boolean flag) {
  844.       boolean oldValue = this.editable;
  845.       this.editable = flag;
  846.       ((JComponent)this).firePropertyChange("editable", oldValue, flag);
  847.       if (super.accessibleContext != null) {
  848.          super.accessibleContext.firePropertyChange("AccessibleState", oldValue ? AccessibleState.EDITABLE : null, flag ? AccessibleState.EDITABLE : null);
  849.       }
  850.  
  851.    }
  852.  
  853.    public void setInvokesStopCellEditing(boolean newValue) {
  854.       boolean oldValue = this.invokesStopCellEditing;
  855.       this.invokesStopCellEditing = newValue;
  856.       ((JComponent)this).firePropertyChange("messagesStopCellEditing", oldValue, newValue);
  857.    }
  858.  
  859.    public void setLargeModel(boolean newValue) {
  860.       boolean oldValue = this.largeModel;
  861.       this.largeModel = newValue;
  862.       ((JComponent)this).firePropertyChange("largeModel", oldValue, newValue);
  863.    }
  864.  
  865.    public void setModel(TreeModel newModel) {
  866.       TreeModel oldModel = this.treeModel;
  867.       this.treeModel = newModel;
  868.       ((JComponent)this).firePropertyChange("treeModel", oldModel, this.treeModel);
  869.       ((Container)this).invalidate();
  870.    }
  871.  
  872.    public void setRootVisible(boolean rootVisible) {
  873.       boolean oldValue = this.rootVisible;
  874.       this.rootVisible = rootVisible;
  875.       ((JComponent)this).firePropertyChange("rootVisible", oldValue, this.rootVisible);
  876.       if (super.accessibleContext != null) {
  877.          ((AccessibleJTree)super.accessibleContext).fireVisibleDataPropertyChange();
  878.       }
  879.  
  880.    }
  881.  
  882.    public void setRowHeight(int rowHeight) {
  883.       int oldValue = this.rowHeight;
  884.       this.rowHeight = rowHeight;
  885.       ((JComponent)this).firePropertyChange("rowHeight", oldValue, this.rowHeight);
  886.       ((Container)this).invalidate();
  887.    }
  888.  
  889.    public void setSelectionInterval(int index0, int index1) {
  890.       TreePath[] paths = this.getPathBetweenRows(index0, index1);
  891.       this.getSelectionModel().setSelectionPaths(paths);
  892.       if (super.accessibleContext != null) {
  893.          ((AccessibleJTree)super.accessibleContext).fireSelectionPropertyChange();
  894.       }
  895.  
  896.    }
  897.  
  898.    public void setSelectionModel(TreeSelectionModel selectionModel) {
  899.       if (selectionModel == null) {
  900.          selectionModel = com.sun.java.swing.JTree.EmptySelectionModel.sharedInstance();
  901.       }
  902.  
  903.       TreeSelectionModel oldValue = this.selectionModel;
  904.       this.selectionModel = selectionModel;
  905.       ((JComponent)this).firePropertyChange("selectionModel", oldValue, this.selectionModel);
  906.       if (super.accessibleContext != null) {
  907.          ((AccessibleJTree)super.accessibleContext).fireSelectionPropertyChange();
  908.       }
  909.  
  910.    }
  911.  
  912.    public void setSelectionPath(TreePath path) {
  913.       this.getSelectionModel().setSelectionPath(path);
  914.       if (super.accessibleContext != null) {
  915.          ((AccessibleJTree)super.accessibleContext).fireSelectionPropertyChange();
  916.       }
  917.  
  918.    }
  919.  
  920.    public void setSelectionPaths(TreePath[] paths) {
  921.       this.getSelectionModel().setSelectionPaths(paths);
  922.       if (super.accessibleContext != null) {
  923.          ((AccessibleJTree)super.accessibleContext).fireSelectionPropertyChange();
  924.       }
  925.  
  926.    }
  927.  
  928.    public void setSelectionRow(int row) {
  929.       int[] rows = new int[]{row};
  930.       this.setSelectionRows(rows);
  931.    }
  932.  
  933.    public void setSelectionRows(int[] rows) {
  934.       TreeUI ui = this.getUI();
  935.       if (ui != null && rows != null) {
  936.          int numRows = rows.length;
  937.          TreePath[] paths = new TreePath[numRows];
  938.  
  939.          for(int counter = 0; counter < numRows; ++counter) {
  940.             paths[counter] = ui.getPathForRow(rows[counter]);
  941.          }
  942.  
  943.          this.setSelectionPaths(paths);
  944.       }
  945.  
  946.    }
  947.  
  948.    public void setShowsRootHandles(boolean newValue) {
  949.       boolean oldValue = this.showsRootHandles;
  950.       this.showsRootHandles = newValue;
  951.       ((JComponent)this).firePropertyChange("showsRootHandles", oldValue, this.showsRootHandles);
  952.       if (super.accessibleContext != null) {
  953.          ((AccessibleJTree)super.accessibleContext).fireVisibleDataPropertyChange();
  954.       }
  955.  
  956.       ((Container)this).invalidate();
  957.    }
  958.  
  959.    public void setUI(TreeUI ui) {
  960.       if ((TreeUI)super.ui != ui) {
  961.          super.setUI(ui);
  962.          ((Component)this).repaint();
  963.       }
  964.  
  965.    }
  966.  
  967.    public void setVisibleRowCount(int newCount) {
  968.       int oldCount = this.visibleRowCount;
  969.       this.visibleRowCount = newCount;
  970.       ((JComponent)this).firePropertyChange("visibleRowCount", oldCount, this.visibleRowCount);
  971.       ((Container)this).invalidate();
  972.       if (super.accessibleContext != null) {
  973.          ((AccessibleJTree)super.accessibleContext).fireVisibleDataPropertyChange();
  974.       }
  975.  
  976.    }
  977.  
  978.    public void startEditingAtPath(TreePath path) {
  979.       TreeUI tree = this.getUI();
  980.       if (tree != null) {
  981.          tree.startEditingAtPath(path);
  982.       }
  983.  
  984.    }
  985.  
  986.    public boolean stopEditing() {
  987.       TreeUI tree = this.getUI();
  988.       return tree != null ? tree.stopEditing() : false;
  989.    }
  990.  
  991.    public void treeDidChange() {
  992.       ((JComponent)this).revalidate();
  993.       ((Component)this).repaint();
  994.    }
  995.  
  996.    public void updateUI() {
  997.       this.setUI((TreeUI)UIManager.getUI(this));
  998.       ((Container)this).invalidate();
  999.    }
  1000.  
  1001.    private void writeObject(ObjectOutputStream s) throws IOException {
  1002.       Vector values = new Vector();
  1003.       s.defaultWriteObject();
  1004.       if (this.cellRenderer != null && this.cellRenderer instanceof Serializable) {
  1005.          values.addElement("cellRenderer");
  1006.          values.addElement(this.cellRenderer);
  1007.       }
  1008.  
  1009.       if (this.cellEditor != null && this.cellEditor instanceof Serializable) {
  1010.          values.addElement("cellEditor");
  1011.          values.addElement(this.cellEditor);
  1012.       }
  1013.  
  1014.       if (this.treeModel != null && this.treeModel instanceof Serializable) {
  1015.          values.addElement("treeModel");
  1016.          values.addElement(this.treeModel);
  1017.       }
  1018.  
  1019.       if (this.selectionModel != null && this.selectionModel instanceof Serializable) {
  1020.          values.addElement("selectionModel");
  1021.          values.addElement(this.selectionModel);
  1022.       }
  1023.  
  1024.       s.writeObject(values);
  1025.    }
  1026. }
  1027.